<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListUsinaLocalizacaoTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form id="form" styleClass="jsfcrud_list_form">
                <p:growl id="messages" life="3000"/>

                <h:panelGroup id="messagePanel" styleClass="ajustaListaMensagemErro"  layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="list"/>
                </h:panelGroup>   

                <h:panelGroup >

                    <p:dataTable value="#{usinaLocalizacaoController.lista}" var="item" rows="10" rowKey="#{item.uslId}" selectionMode="single" emptyMessage="#{bundle.ListUsinaLocalizacaoEmpty}"
                                 paginator="true" paginatorPosition="both" rowsPerPageTemplate="5,10,15,20" selection="#{usinaLocalizacaoController.selectedUsinaLocalizacao}"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >

                        <p:column styleClass="firstColumn" filterBy="#{item.uslId}" sortBy="#{item.uslId}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListUsinaLocalizacaoTitle_uslId}"/>
                            </f:facet>
                            <h:outputText value="#{item.uslId}"/>
                        </p:column>
                        <p:column filterBy="#{item.uslUsiId.usiNm}" sortBy="#{item.uslUsiId.usiNm}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListUsinaLocalizacaoTitle_uslUsiId}"/>
                            </f:facet>
                            <h:outputText value="#{item.uslUsiId.usiNm}"/>
                        </p:column>
                        <p:column filterBy="#{item.uslUfdCd.ufdSg}" sortBy="#{item.uslUfdCd.ufdSg}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListUsinaLocalizacaoTitle_uslUfdCd}"/>
                            </f:facet>
                            <h:outputText value="#{item.uslUfdCd.ufdSg}"/>
                        </p:column>
                        <p:column filterBy="#{item.uslMunCd.munNm}" sortBy="#{item.uslMunCd.munNm}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListUsinaLocalizacaoTitle_uslMunCd}"/>
                            </f:facet>
                            <h:outputText value="#{item.uslMunCd.munNm}"/>
                        </p:column>
                        <p:column filterBy="#{item.uslRioCd.rioNm}" sortBy="#{item.uslRioCd.rioNm}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListUsinaLocalizacaoTitle_uslRioCd}"/>
                            </f:facet>
                            <h:outputText value="#{item.uslRioCd.toString()}"/>
                        </p:column>



                        <f:facet name="footer">                            
                            <p:commandButton id="createCommand" ajax="false" icon="ui-icon-document" action="#{usinaLocalizacaoController.prepareCreate}" value="#{bundle.ListUsinaLocalizacaoCreateLink}"/>
                            <p:commandButton id="viewCommand" actionListener="#{usinaLocalizacaoController.carregaRios()}" value="#{bundle.MsgVisualizar}" icon="ui-icon-search"  update=":formList:displayView" oncomplete="usinaLocalizacaoDialogView.show()" />
                            <p:commandButton id="editCommand" ajax="false" action="#{usinaLocalizacaoController.prepareEdit}" value="#{bundle.ViewUsinaLocalizacaoEditLink}" icon="ui-icon-pencil" />
                            <p:commandButton id="deleteCommand"  onclick="confirmationDestroy.show()" value="#{bundle.ViewUsinaLocalizacaoDestroyLink}" type="button" icon="ui-icon-trash" />
                        </f:facet>
                    </p:dataTable>

                    <p:confirmDialog id="confirmDestroy" message="#{bundle.MsgConfirmDestroy_message}" header="#{bundle.MsgConfirmDestroy_header}" severity="alert" widgetVar="confirmationDestroy">
                        <p:commandButton id="confirm" ajax="false" value="#{bundle.MsgDialog_confirmar}"  oncomplete="confirmationDestroy.hide();" actionListener="#{usinaLocalizacaoController.destroy}" />
                        <p:commandButton id="decline"  value="#{bundle.MsgDialog_cancelar}" update="messages" onclick="confirmationDestroy.hide()" type="button"/>

                    </p:confirmDialog>

                    <p:dialog id="dialogView" header="#{bundle.UsinaLocalizacaoDialogView_header}" widgetVar="usinaLocalizacaoDialogView" resizable="false"
                              width="500" >

                        <h:panelGrid id="displayView" columns="2" cellpadding="4">                          

                            <h:outputText value="#{bundle.ViewUsinaLocalizacaoLabel_uslId}"/>
                            <h:outputText value="#{usinaLocalizacaoController.selected.uslId}" title="#{bundle.ViewUsinaLocalizacaoTitle_uslId}"/>
                            <h:outputText value="#{bundle.ViewUsinaLocalizacaoLabel_uslUsiId}"/>
                            <h:outputText value="#{usinaLocalizacaoController.selected.uslUsiId.usiNm}" title="#{bundle.ViewUsinaLocalizacaoTitle_uslUsiId}"/>
                            <h:outputText value="#{bundle.ViewUsinaLocalizacaoLabel_uslUfdCd}"/>
                            <h:outputText value="#{usinaLocalizacaoController.selected.uslUfdCd.ufdSg}" title="#{bundle.ViewUsinaLocalizacaoTitle_uslUfdCd}"/>
                            <h:outputText value="#{bundle.ViewUsinaLocalizacaoLabel_uslMunCd}"/>
                            <h:outputText value="#{usinaLocalizacaoController.selected.uslMunCd.munNm}" title="#{bundle.ViewUsinaLocalizacaoTitle_uslMunCd}"/>                          
                            <h:outputText value="#{bundle.ViewUsinaLocalizacaoLabel_subbacia}"/>
                            <h:outputText value="#{usinaLocalizacaoController.subbacia.toString()}" title="#{bundle.ViewUsinaLocalizacaoTitle_subbacia}"/>
                            <h:outputText value="#{bundle.ViewUsinaLocalizacaoLabel_uslRioCd}"/>
                            <h:outputText value="#{usinaLocalizacaoController.selected.uslRioCd.toString()}" title="#{bundle.ViewUsinaLocalizacaoTitle_uslRioCd}"/>
                        </h:panelGrid>
                    </p:dialog>

                </h:panelGroup>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
